<template>
  <div class="login-wrap">
    <div class="ms-login">
      <div class="ms-title">登录</div>
      <el-form
        :model="param"
        :rules="rules"
        ref="login"
        label-width="0px"
        class="ms-content"
      >
        <el-form-item prop="username">
          <el-input v-model="param.username" placeholder="用户名"> </el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input
            type="密码"
            placeholder="密码"
            v-model="param.password"
          >
          </el-input>
        </el-form-item>
        <div class="login-btn">
          <el-button type="primary" @click="submitForm" round>登录</el-button>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      param: {
        username: "",
        password: "",
      },
      rules: {
        username: [
          { required: true, message: "请输入用户名", trigger: "blur" }
        ],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
      },
    };
  },
  methods: {
    submitForm() {
      this.$refs.login.validate((valid) => {
        if (valid) {
          this.$message.success("登录成功");
          console.log("true");
          this.$router.push("/home");
        } else {
          alert("错误，请重新输入！");
        }
      });
    },
  },
};
</script>

<style scoped>
.login-wrap {
  height: 97.6vh;
  background:#9cd6fa;
}
.ms-title {
  width: 100%;
  line-height: 50px;
  text-align: center;
  font-size: 25px;
  color: #23a3b7;
  border-bottom: 1px solid #fff;
}
.ms-login {
  position: absolute;
  left: 48%;
  top: 50%;
  width: 400px;
  padding: 40px;
  margin: -190px 0 0 -175px;
  border-radius: 5px;
  background: #bbdff7;
  box-shadow: 0 15px 25px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.ms-content {
  padding: 30px 30px;
}
.login-btn {
  text-align: center;
}
.login-btn button {
  width: 100%;
  height: 36px;
  margin-bottom: 10px;
}
</style>